import http from '@/plugins/aixos'
import { wireModel } from '@/types/model'

export const addWire = async (data: wireModel) => {
  return await http.request<wireModel>({
    url: `/wire`,
    data,
    method: 'POST',
  })
}

export const findAllWire = async (args: Record<string, any>) => {
  const url =
    'wire?' +
    Object.entries(args)
      .map(([key, value]) => `${key}=${value}`)
      .join('&')
  return await http.request<wireModel[]>({
    url,
    method: 'GET',
  })
}

export const findWireById = async (id: number) => {
  return await http.request<wireModel>({
    url: `/wire/${id}`,
    method: 'GET',
  })
}

export const delWires = async (id: number) => {
  return await http.request({
    url: `/wire/wires/${id}`,
    method: 'DELETE',
  })
}
